﻿module Sustainalytics.Shell {

    import Authentication = Sustainalytics.Authentication;

    export class ShellController {

        constructor(
            private AuthenticationService: Authentication.IAuthenticationService) {
        }

        public logout() {
            this.AuthenticationService.logout();
        }
    }

    angular.module('shell').controller('ShellController', ['AuthenticationService', ShellController]);
}



//angular.module('shell').controller('ShellController', ['$scope', '$route', '$routeParams', '$location', '$rootScope', 'staticObjects', 'accountFactory', 'notificationFactory', 'companyReportsFactory', 'reportNotificationFactory', 'userInfoFactory', 'logFactory', 'ClaimsAuthorizationService',
//    (
//        $scope,
//        $route,
//        $routeParams,
//        $location,
//        $rootScope,
//        staticObjects: IStaticObjects,
//        accountFactory: IAccountFactory,
//        notificationFactory: INotificationFactory,
//        companyReportsFactory: IReportsFactory,
//        reportNotificationFactory: IReportNotificationFactory,
//        userInfoFactory: IUserInfoFactory,
//        logFactory: ILogFactory,
//        ClaimsAuthorizationService: Sustainalytics.Claims.ClaimsAuthorizationService) => {
    
//    $scope.authData = $rootScope.authData;
//    $rootScope.$watch('authData', (newValue, oldValue) => {
//        $scope.authData = newValue;
//    });
//    $scope.userInfo = $rootScope.userInfo;
//    $rootScope.$watch('userInfo', (newValue, oldValue) => {
//        $scope.userInfo = newValue;
//    });

//    //$scope.reportNotification = $rootScope.reportNotification;
//    //$rootScope.$watch('reportNotification', (newValue:IReportNotification, oldValue) => {
//    //    $scope.reportNotification = newValue;
//    //    if (!$scope.$$phase) { $scope.$apply(); }
//    //});

//    $scope.$on('$routeChangeSuccess', (e, current, previous) => {
//        //var path = $location.path();
//        //var cleanPath = path;
//        //if (path.slice(0, '/changePassword'.length) == '/changePassword')
//        //    cleanPath = path.slice(0, '/changePassword'.length);
//        $scope.activeViewPath = $location.path();
//        //$location.path(cleanPath);
//        //e.preventDefault();
//    });

//    //$scope.running = () => {
//    //    if ($scope.reportNotification.Finished != undefined && $scope.reportNotification.Finished != '') {
//    //        return false;
//    //    } else {
//    //        return true;
//    //    }
//    //};

//    var errorCallback = (data, status, headers, config) => {
//        $scope.loading = false;
//        if (data!="") {
//            notificationFactory.error(data.ExceptionMessage, data.message);
//        } else {
//            notificationFactory.error(status, staticObjects.getErrorMesageByStatusCode(status));
//        }
//    };
    

//    //$scope.cancel = () => {
//    //    $scope.loading = true;
//    //    companyReportsFactory.cancelReport().success(() => {
//    //        $scope.loading = false;
//    //    }).error(errorCallback);
//    //};
    

//    //var reportTickerHubProxy = $.connection.reportsManagerHub;
//    //reportTickerHubProxy.client.broadcastReportsUpdateStatus = (reportNotification: IReportNotification) => {
//    //    if (reportNotification.Error != undefined && reportNotification.Error != '') {
//    //        notificationFactory.error("", reportNotification.Error);
//    //    }
//    //    if (reportNotification.Finished) {
//    //        var utcDate = new Date();
//    //        logFactory.log({ username: $scope.userInfo.name, reportType: reportNotification.ReportType, startReportRequest: null, endReportRequest: utcDate, error: reportNotification.Error, status: reportNotification.Status })
//    //        .error(errorCallback);
//    //    }
//    //    $rootScope.reportNotification = reportNotification;
//    //    $scope.reportNotification = reportNotification;
//    //    if (!$scope.$$phase) { $scope.$apply(); }
//    //};

//    $scope.logout = () => {
//        accountFactory.logout();
//    };
//}]); 
